package view;

import java.util.HashMap;

import javax.swing.JTabbedPane;

import bot.ChatBot;

public class ChatOverviewPanel extends JTabbedPane {
	ChatBot bot;
	HashMap<String, ChannelTab> tabs;

	public ChatOverviewPanel() {
		this.tabs = new HashMap<String, ChannelTab>();
	}

	public ChannelTab addTab(String channel) {
		ChannelTab chat = new ChannelTab(channel, bot);
		this.add(chat);
		tabs.put(channel, chat);
		return chat;
	}

	public void setBot(ChatBot bot) {
		this.bot = bot;
	}

	public void addText(String channel, String sender, String message) {
		ChannelTab chat = tabs.get(channel);
		if (chat == null) {
			chat = addTab(channel);
		}
		chat.addText(sender, message);
	}

	public void addText(String sender, String message) {
		ChannelTab chat = tabs.get(sender);
		if (chat == null) {
			chat = addTab(sender);
		}
		chat.addText(sender, message);
	}
}
